﻿/*
 * Name:        SnkPanel
 * Description: UI part that acts as a Panel
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

using Gyvate.Worldspawn;
using Gyvate.Util;

namespace Gyvate.GFX
{
    internal class SnkPanel
    {
        protected Dimensions2d m_dimensions;
        protected Game m_game;
        protected Brush m_bgBrush;
        protected bool m_bIsVisible;

        public Dimensions2d GetDimensions() { return m_dimensions; }        //Gets dimensions of the UI control
        public bool IsVisible() { return m_bIsVisible; }
        public void SetVisible(bool visible) { m_bIsVisible = visible; }

        /*
         * Constructor with Dimensions2D param
         */
        public SnkPanel(Game game, Dimensions2d dim)
        {
            ApplyScheme(dim);
            m_game = game;
        }

        /*
         * Constructor with 2x Vector2f params that will be turned into Dimensions2d
         */
        public SnkPanel(Game game, Vector2d pos, Vector2d size)
        {
            ApplyScheme(new Dimensions2d(pos, size));
            m_game = game;
        }

        /*
         * Applies default scheme settings
         */
        internal virtual void ApplyScheme(Dimensions2d dim)
        {
            m_bIsVisible = true;
            m_dimensions = dim;
            SetBGColour(Color.Black);
        }

        /*
         * Sets background colour
         */
        public void SetBGColour(Color colour)
        {
            m_bgBrush = new SolidBrush(colour);
        }
    
        /*
         * Draws to buffer
         */
        internal virtual void Draw()
        {
            if (!IsVisible())
                return;

            m_game.GetUIParent().FillRectangle(m_bgBrush, m_dimensions.pos.x, m_dimensions.pos.y, m_dimensions.size.x, m_dimensions.size.y);
        }
    }
}
